#include <stdio.h>
#include <unistd.h>

int retNum()
{
    return exit(0);
}

void test1()
{
    char str1[] = "fwrite\n";
    char str2[] = "write\n";
    printf("printf\n");
    fprintf(stdout,"fprintf\n");
    fwrite(str1,sizeof(str1),1,stdout);
    write(1,str2,sizeof(str2));
    close(1);
    //重定向后只会写入write内容
}

void test2()
{
    char str1[] = "fwrite\n";
    char str2[] = "write\n";
    printf("printf\n");
    fprintf(stdout,"fprintf\n");
    fwrite(str1,sizeof(str1),1,stdout);
    write(1,str2,sizeof(str2));
    fork();
    //子进程会写时拷贝父进程的缓冲区
}

int main()
{
    
    // fflush(stdout); // 刷新缓冲区
    
    // _exit(0);//直接退出整个程序
    
    return 0;
}